


export default abstract class BaseAssembler {

    abstract updateRenderData (comp:cc.RenderComponent);

    abstract fillBuffers (comp:cc.RenderComponent, renderer);

    getBuffer () {
        return cc.renderer['_handle']._meshBuffer;
        // cc.renderer['_handle'].getBuffer('mesh',xxxx)
    }

    // getVfmt () {
    //     let b:cc.Mesh;
    //     b.init()
    //     return cc.gfx.vfmtPosUvColor;
    // }

    protected packToDynamicAtlas (comp:cc.RenderComponent, frame:cc.SpriteFrame) {
        if (CC_TEST) return;
        if(!frame) return;
        if (!frame['_original'] && cc.dynamicAtlasManager && frame['_texture'].packable) {
            let packedFrame = <any>cc.dynamicAtlasManager.insertSpriteFrame(frame);
            if (packedFrame) {
                frame['_setDynamicAtlasFrame'](packedFrame);
            }
        }
        let material = comp['_materials'][0];
        if (!material) return;
        
        if (material.getProperty('texture') !== frame['_texture']) {
            // texture was packed to dynamic atlas, should update uvs
            comp['_vertsDirty'] = true;
            comp['_updateMaterial']();
        }
    }
}